package com.efast.cafe.portal.open.tcp;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

import com.efast.cafe.commponent.es.tcp.annotation.TcpHandler;
import com.efast.cafe.commponent.es.tcp.base.TcpAbstractHandler;
import com.efast.cafe.commponent.es.tcp.bean.TcpData;

@TcpHandler(command={0x54,0x45,0x53,0x54},version=0x05)
public class TestHandler extends TcpAbstractHandler{

	
	    
	    
	@Override
	public byte[] handMessage(TcpData data) throws Exception {
		System.out.println(data);
		System.out.println(new String(data.getContent(),"utf-8"));
		return null;
	}
	
//	public static void main(String[] args) throws UnknownHostException, IOException {
//         //1.建立TCP连接
//		String ip="127.0.0.1";   //服务器端ip地址
//		int port=9094;        //端口号
//		Socket sck=new Socket(ip,port);
//		//2.传输内容
//		OutputStream os=sck.getOutputStream();   //输出流
//		//数据
//		byte[] cs = {0x7e,0x05,0x54,0x45,0x53,0x54,0x0B,0x00,0x74,0x68,0x69,0x73,0x20,0x61,0x20,0x74,0x65,0x73,0x74,0x00,0x00,0x7e};
//		os.write(cs);
//		//3.关闭连接
//		sck.close();
//	}

}
